package counsel;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import code.CodeDAO;
import code.CodeDTO;

public class CounselView extends HttpServlet{
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		req.setCharacterEncoding("utf-8");
		
		String cs_no = req.getParameter("cs_no");
		CounselDTO coun = new CounselDTO();
		coun.setCs_no(cs_no);
		CounselDAO dao = new CounselDAO();
		dao.setCoun(coun);
		CounselDTO dto = dao.view();
		
		req.setAttribute("dto", dto);
		
		//공통코드 관련
		CodeDTO code = new CodeDTO();
		CodeDAO cdao = new CodeDAO();
		//계약상태
		code.setCd_grp1("CTING");
		cdao.setDto(code);
		ArrayList<CodeDTO> codes = cdao.returnCode();
		req.setAttribute("ctings", codes);
		//직급
		cdao = new CodeDAO();
		code.setCd_grp1("PST");
		cdao.setDto(code);
		codes = cdao.returnCode();
		req.setAttribute("psts", codes);
		//부서
		cdao = new CodeDAO();
		code.setCd_grp1("SADP");
		cdao.setDto(code);
		codes = cdao.returnCode();
		req.setAttribute("sadps", codes);
		
		req.getRequestDispatcher("/intranet/index.jsp?inc_content=./counsel/counsel_edit.jsp").forward(req, resp);
	}
	
}
